package com.idcf.boathouse.product.controller;

import com.idcf.boathouse.product.services.LoginService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName:LoginController
 * @Description:TODO
 * @Author:joyking
 * @Date:2020/12/30 1:43 AM
 * @Version:1.0
 **/

@RestController
@Api(tags = "Login Test API")
@RequestMapping("/Login/*")
public class LoginController {
    @Autowired
    LoginService loginService;
    @RequestMapping(value = "Login", method = RequestMethod.PUT, produces = {"application/json;charset=UTF-8"})
    @ResponseBody
    @ApiOperation("登录接口")
    public String login(String username,String password){
        if(loginService.verifyPass(username,password))
            return "登录成功";
        else
            return "用户名或者密码不对";
    }

    @RequestMapping(value = "Register", method = RequestMethod.PUT, produces = {"application/json;charset=UTF-8"})
    @ResponseBody
    @ApiOperation("注册接口")
    public String register(String username,String password){
        if(loginService.register(username,password))
            return "注册成功";
        else
            return "注册失败";
    }
}
